from PIL import Image
import argparse
SCREEN_W, SCREEN_H = 640, 480
MEM_W, MEM_H = 1<<10, 1<<9
parser = argparse.ArgumentParser()
parser.add_argument('-i', dest='ipt')
parser.add_argument('-w', dest='width', type=int)
parser.add_argument('-h', dest='hight', type=int)
parser.add_argument('-o', dest='opt')
args = parser.parse_args()

img = Image.open(args.ipt).convert("RGB")
        
img_resized = img.resize((args.width, args.height), Image.Resampling.LANCZOS)

pixels = list(img_resized.getdata())

with open(args.opt, 'w') as f:
    f.write('@000000')
    for r, g, b in pixels:
        rgb = (r << 16) | (g << 8) | b
        f.write(f'rgb:{06X}\n')
